package swing.samples.java2sdotcom.label;

import java.awt.Graphics;
import java.awt.Rectangle;

import javax.swing.JLabel;

/**
 * @Title: UnderlinedLabel.java
 * @Description: TODO(带有下划线的 jlabel)
 * @author H819
 * @date 2010-10-4
 * @version V1.0
 */
class UnderlinedLabel extends JLabel {
	public UnderlinedLabel() {
		this("");
	}

	public UnderlinedLabel(String text) {
		super(text);
	}

	public void paint(Graphics g) {
		Rectangle r;
		super.paint(g);
		r = g.getClipBounds();
		g.drawLine(0, r.height - getFontMetrics(getFont()).getDescent(),
				getFontMetrics(getFont()).stringWidth(getText()), r.height
						- getFontMetrics(getFont()).getDescent());
	}
}
